import UIKit

protocol UIIdentificationProtocol {
    
    func ant_identification() -> String
    
}
let mainColor = UIColor.color(hexString: "#E5F789")

let titleColor = UIColor.color(hexString: "#333333")

class BasicViewController: UIViewController, UIIdentificationProtocol {
    
    func ant_identification() -> String {
        return NSStringFromClass(self.classForCoder)
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        NSObject.cancelPreviousPerformRequests(withTarget: self)
    }
    
    override func viewDidLoad() {
        
        super.viewDidLoad()
        view.backgroundColor = .black
        
//        // 设置单个页面不跟随暗黑模式改变
//        self.overrideUserInterfaceStyle = .light
//        view = ScreenShieldView.create()
//        if let img = UIImage.image(named: "pageBackImg") {
//            view.backgroundColor = UIColor.init(patternImage: self.imageScaledToSize(size: .init(width: UITool.screenWidth, height: UITool.screenHeight), image: img))
//        }
//        view.emptyState.format.imageSize = CGSize(width: 90.Fit, height: 90.Fit)
//        view.emptyState.format.backgroundColor = .clear
//        view.emptyState.format.descriptionAttributes = [.font: UIFont.setTypeFace(14, type: .medium), .foregroundColor: UIInterfaceConfig.color.descriptionColor]
//        view.emptyState.format.buttonColor = UIInterfaceConfig.color.hightlightColor
//        view.emptyState.format.buttonAttributes = [.font: UIFont.setTypeFace(14, type: .bold),.foregroundColor : UIInterfaceConfig.color.lightBlackColor]
//        view.emptyState.format.verticalMargin = 0
        
    }
    
    func setRightItem(_ v:UIView) -> Void {
        self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(customView: v)
    }
    
    func setCustomerLeftItem(_ v:UIView) -> Void {
        self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(customView: v)
    }
    
    func setLeftItem(str:String) {
        let lefB = UIButton.initV(font: .setTypeFace(20,type: .bold), text: "About you", img: "return")
        lefB.addAct {
            self.navigationController?.popViewController(animated: true)
        }
        self.navigationItem.leftBarButtonItem=UIBarButtonItem.init(customView: lefB)
    }
    
    @objc func leftAction() {
    }
    

    func imageScaledToSize(size: CGSize, image: UIImage) -> UIImage {
        UIGraphicsBeginImageContextWithOptions(size, false, 0.0);
        image.draw(in: CGRectMake(0.0, 0.0, size.width, size.height))
        guard let imageR = UIGraphicsGetImageFromCurrentImageContext() else { return image }
        UIGraphicsEndImageContext();
        return imageR;
    }
    
//    override var preferredStatusBarStyle: UIStatusBarStyle {
//        return .lightContent
//    }
    
    deinit {
//        print("----------------------------\n" + self.description + "控制器销毁了" + "\n----------------------------", logLevel: .current)
        NotificationCenter.default.removeObserver(self)
    }
}
